<template>
  <BaseButton :disabled="disabled" :config="config" @click="addNew"/>
</template>
<script>
import BaseButton from '@comp/hhd/design/FormMenu/button/base/BaseButton.vue';
import {createProps} from '@/utils';

export default {
  name: 'EditButton',
  components: {
    BaseButton
  },
  props: {
    selectedRows: createProps(Array, () => []),
    config: createProps(Object, () => ({})),
  },
  methods: {
    addNew() {
      this.$emit('editRow', {viewId: this.config.config.viewId, actionId: this.config.config.actionId, formDataId: this.selectedRows[0].id});
    },
  },
  computed: {
    disabled() {
      if (this.selectedRows && this.selectedRows.length != 1) return true;
      return false;
    },
  }
};
</script>